package tut.collection.marinHashMap;

import java.util.HashMap;

public class TestMarinummaryKey {
	public static void main(String[] args) {
		HashMap<MarinSummaryKey, MarinValue> map = new HashMap<MarinSummaryKey, MarinValue>();

		MarinSummaryKey key = new MarinSummaryKey(1, 2);
		MarinValue value = new MarinValue(100, 65);

		map.put(key, value); // tinh hashcode, roi moi add

		key = new MarinSummaryKey(1, 2);
		value = new MarinValue(100, 65);

		map.put(key, value); // hashcode jong nhau nen chay vao equals xem co trung nhau khong

		key = new MarinSummaryKey(3, 4);
		value = new MarinValue(100, 62);

		map.put(key, value); // tinh hashcode ra khong giong voi thang nao trong map nen khong chay vao equals nua


		key = new MarinSummaryKey(2, 5);
		value = new MarinValue(100, 62);

		map.put(key, value); // tinh hashcode ra trung nhau (voi thang 3,4) nen chay va equals thay false nen se add vao map

		// value = map.get(new MarinSummaryKey(1, 2));

		value = map.get(new MarinSummaryKey(6, 5)); // tinh hashcode khac nhau nen khong chay vao equals nua

		value = map.get(new MarinSummaryKey(0, 3)); // tinh hashcode thay giong thang (1,2) nen chay vao equals thay khong co tra ve null;

		System.out.println(map);
		System.out.println(value);
	}

}
